package com.huawei.M01.iterator.A24;

import java.util.Arrays;
import java.util.Comparator;

/**
 * 按身高排序
 *
 * @author zhiwu
 */
public class SortPeople {
    public String[] sortPeople(String[] names, int[] heights) {
        int n = names.length;
        Object[][] people = new Object[n][n];
        for (int i = 0; i < n; i++) {
            people[i][0] = names[i];
            people[i][1] = heights[i];
        }
        Arrays.sort(people, (a, b) -> (int)b[1] - (int)a[1]);
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = (String)people[i][0];
        }
        return res;
    }

}
